<template>
	<!-- 固定在底部的按钮 -->
	<view class="btn-footer space-x-1 px-1 btn_position">
		<u-button type="primary" :plain="true" text="关闭" @click="closeAndJump"></u-button>
		<slot>
		<u-button v-if="showSaveBtn" :disabled="avoidRepeatSubmitFlag" type="primary" text="提交" @click="submitData"></u-button>
		</slot>
	</view>
</template>

<script>
	export default {
		name:"fixedBottomButtons",
		data(){
			return {
			}
		},
		props:{
			backPath:{
				type:String,
				required:false
			},
			avoidRepeatSubmitFlag:{
				type:Boolean,
				required:false,
				default:false
			},
			showSaveBtn:{
				type:Boolean,
				default:true
			}
		},
		methods:{
			// 关闭并且跳转到指定页面，限制只能跳转到底部的三个页面
			closeAndJump(){
				this.$utils.uniDlgCallBack({
					title: '提示',
					content: '是否关闭？',
					success: ()=>{
						uni.reLaunch({
							url: this.backPath
						})
					}
				})
			},
			// 上传数据
			submitData(){
				// 如果上传成功,关闭页面
				// 数据上传成功前禁用提交按钮
				this.$emit('clickSubmit')
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import url("@/assets/inputStyle.scss");
</style>